import Vue from 'vue'
import App from './App.vue'
import 'amfe-flexible'
import router from './router'
import 'vant/lib/index.css';
import 'vant/lib/index.less';
import lodash from 'lodash'
import {
    Area,
    Lazyload,
    Button,
    NoticeBar,
    Toast,
    Swipe,
    SwipeItem,
    Cell,
    CellGroup,
    Tabbar,
    TabbarItem,
    Icon,
    Form,
    Field,
    Radio,
    RadioGroup,
    Tab,
    Tabs,
    NavBar,
    Calendar,
    Uploader,
    Popup,
    List,
    Tag,
    Sticky,
    Empty,
    Search,
    Picker
} from 'vant';
import VCharts from 'v-charts'
import moment from 'moment'
import {
    checkRole
} from '@/utils/func'
import './wxShareConfig'

//设置每个页面标题
router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

Vue.config.productionTip = false
Vue.prototype.$_ = lodash
Vue.prototype.$moment = moment
Vue.prototype.$getToken = () => {
    return localStorage.getItem('token')
}
Vue.prototype.$getUserInfo = () => {
    let userInfo
    if (localStorage.getItem('userInfo')) {
        userInfo = JSON.parse(localStorage.getItem('userInfo'))
        return userInfo.sysUser || userInfo
    }
    return {}
}
Vue.prototype.$setUserInfo = (userInfo) => {
    localStorage.setItem('userInfo', JSON.stringify(userInfo))
}
Vue.prototype.$checkRole = checkRole


// Vue.use(Vant);
Vue.use(Lazyload)
Vue.use(Swipe)
Vue.use(SwipeItem)
Vue.use(Button)
Vue.use(CellGroup)
Vue.use(Cell)
Vue.use(Tabbar)
Vue.use(TabbarItem)
Vue.use(Icon)
Vue.use(Form)
Vue.use(Field)
Vue.use(Radio)
Vue.use(RadioGroup)
Vue.use(Tab)
Vue.use(Tabs)
Vue.use(Toast)
Vue.use(NoticeBar)
Vue.use(NavBar)
Vue.use(Calendar)
Vue.use(Uploader)
Vue.use(Popup)
Vue.use(Area)
Vue.use(Tag)
Vue.use(List)
Vue.use(Sticky)
Vue.use(Empty)
Vue.use(Search)
Vue.use(Picker)

//引入图表
Vue.use(VCharts)


new Vue({
    router,
    render: h => h(App)
}).$mount('#app')